#include <glib/g2/types.h>
#include <glib/g2/circle.h>
#include <glib/g2/region.h>
#include <math/pi.h>

namespace g2 {

circle::circle(const vector & center, double radius) : 
	_center(center), _radius(radius)
{
}

double circle::radius() const
{
	return _radius;
}

void circle::radius(double r)
{
	_radius = r;
}

region circle::flatten(double h) const
{
	if (_radius == 0)
		return region(contour(std::vector<vector>(1, _center)));
	size_type count = size_type(2 * PI * _radius / h);
	contour c((std::vector<vector>(count)));
	for (size_type i = 0; i < count; ++i) {
		double a = (2 * PI * i) / count;
		c[i] = _center + vector(cos(a), sin(a)) * _radius;
	}
	return region(c);
}

vector circle::center() const
{
	return _center;
}

box circle::bounds() const
{
	return box(_center).inflate(_radius, _radius);
}

void circle::translate(const vector & t)
{
	_center += t;
}

void circle::rotate(const vector & center, double angle)
{
	// 
	assert(false);
}

} // g2
